<script lang="ts" setup>
import { onMounted, ref } from 'vue';
import { useRouter } from 'vue-router';

import { Page } from '@vben/common-ui';

import { useFs } from '@fast-crud/fast-crud';

import { createCrudOptions } from '../data/user-list-crud';

defineOptions({
  name: '企业用户查看',
  inheritAttrs: false,
});

const { currentRoute } = useRouter();
const tenantId = ref<string>();
const { crudRef, crudBinding, crudExpose } = useFs({
  createCrudOptions,
  context: { tenantId },
});

// 页面打开后获取列表数据
onMounted(async () => {
  const { params } = currentRoute.value;
  tenantId.value = params.id as string;

  // crudExpose.setSearchFormData({ form: { tenantId: params.id } });
  crudExpose.doRefresh();
});
</script>

<template>
  <Page auto-content-height>
    <FsCrud ref="crudRef" v-bind="crudBinding" />
  </Page>
</template>
